$(document).ready(function(){
		var win = window.dialogArguments;
		var url = '/schedule/queryCourseRClass?flag='+win;
		var j = 0;
		$.ajax({
			url: url,
			success:function(data){
				$(data.root).each(function(i,teachersRCourse){
					if((i-2)%3==0){
						j++;
						$("#data").append("<tr><td width='33%'><li value='"+data.root[i-2].id+"'>"+data.root[i-2].course.course_name+"("+data.root[i-2].teachers.teachers_name+")  " + data.root[i-2].course.course_totaltime + "</li></td><td width='34%'><li value='"+data.root[i-1].id+"'>"+data.root[i-1].course.course_name+"("+data.root[i-1].teachers.teachers_name+")  " + data.root[i-1].course.course_totaltime + "</li></td><td width='33%'><li value='"+data.root[i].id+"'>"+data.root[i].course.course_name+"("+data.root[i].teachers.teachers_name+")  " + data.root[i].course.course_totaltime + "</li></td></tr>");
					}else if(data.root.length-3*j==2){
						$("#data").append("<tr><td width='33%'><li value='"+data.root[data.root.length-2].id+"'>"+data.root[data.root.length-2].course.course_name+"("+data.root[data.root.length-2].teachers.teachers_name+")  " + data.root[data.root.length-2].course.course_totaltime + "</li></td><td width='34%'><li value='"+data.root[data.root.length-1].id+"'>"+data.root[data.root.length-1].course.course_name+"("+data.root[data.root.length-1].teachers.teachers_name+")  " + data.root[data.root.length-1].course.course_totaltime + "</li></td></tr>");	
						return false;
					}else if(data.root.length-3*j==1){
						$("#data").append("<tr><td width='34%'><li value='"+data.root[data.root.length-1].id+"'>"+data.root[data.root.length-1].course.course_name+"("+data.root[data.root.length-1].teachers.teachers_name+")  " + data.root[data.root.length-1].course.course_totaltime + "</li></td></tr>");
						return false;
					}
				});
			}
	});
	$("li").live('mouseover',function(event){
			$(this).css("cursor","pointer");
		}).live('click',function(event){
			var newwin = window.showModalDialog("choiceClassroom.jsp", "", "dialogTop:"+event.screenY +"px;dialogWidth:700px;dialogHeight:300px; dialogLeft:"+event.screenX+"px;modal=yes");
			if(newwin!=null){
				if(newwin!=""){
					window.returnValue = $(this).attr("value")+"-"+newwin+"-"+$(this).text();//teachersRCourseID+classroomId+classroomName+courseName(teacherName)
					window.close();
				}
			}	
			
		});
});